home *** CD-ROM | disk | FTP | other *** search
/ ftp.hitl.washington.edu / ftp.hitl.washington.edu.tar / ftp.hitl.washington.edu / pub / people / tsoper / CT Explorer / ViewPanel.cs < prev    next >
Text File  |  2005-06-08  |  3KB  |  116 lines

  1. using System;
  2. using System.Windows.Forms;
  3. using System.Drawing;
  4. using SampleGUI;
  5.  
  6.  
  7. public class ViewPanel : Panel
  8. {
  9.     //declarations
  10.  
  11.     //MAKE THESE PRIVATE
  12.     public SliceView mainSliceView; // main view
  13.     private SliceView[] orthoSliceView; //smaller orthogonal views
  14.     private System.Windows.Forms.Panel mainViewPanel; //panel to hold main view
  15.     private System.Windows.Forms.Panel orthoViewBigPanel; //panel to hold all ortho views
  16.     private System.Windows.Forms.Panel[] orthoViewPanel; //panels to hold each ortho view
  17.  
  18.     //TAKE THIS OUT
  19.     public Label lbl;
  20.  
  21.     public ViewPanel()
  22.     {
  23.  
  24.         //instantiate controls
  25.         mainSliceView = new SliceView();
  26.         orthoSliceView = new SliceView[3];
  27.         mainViewPanel = new Panel();
  28.         orthoViewBigPanel = new Panel();
  29.         orthoViewPanel = new Panel[3];
  30.         for(int i = 0; i < 3; i++)
  31.         {
  32.             orthoSliceView[i] = new SliceView();
  33.             orthoViewPanel[i] = new Panel();
  34.         }
  35.         
  36.         //suspend layout
  37.         this.SuspendLayout();
  38.         
  39.         //set containers
  40.         mainViewPanel.Controls.Add(mainSliceView);
  41.         for(int i = 0; i < 3; i++)
  42.         {
  43.             orthoViewPanel[i].Controls.Add(orthoSliceView[i]);
  44.             orthoViewBigPanel.Controls.Add(orthoViewPanel[i]);
  45.         }
  46.         this.Controls.Add(mainViewPanel);
  47.         this.Controls.Add(orthoViewBigPanel);
  48.  
  49.         //set Dock Styles and border styles
  50.         mainSliceView.Dock = DockStyle.Fill;
  51.         for(int i = 0; i < 3; i++)
  52.         {
  53.             orthoSliceView[i].Dock = DockStyle.Fill;
  54.             orthoViewPanel[i].Dock = DockStyle.Right;
  55.             orthoViewPanel[i].BorderStyle = BorderStyle.Fixed3D;
  56.         }
  57.         orthoViewBigPanel.BorderStyle = BorderStyle.Fixed3D;
  58.         mainViewPanel.BorderStyle = BorderStyle.Fixed3D;
  59.  
  60.         //set the view planes
  61.         mainSliceView.ViewType = VIEW_TYPE.CORONAL;
  62.         mainSliceView.IsRotatable = true;
  63.         mainSliceView.IsZoomable = true;
  64.         mainSliceView.eye.MaxZoom = 5.0f;
  65.         mainSliceView.eye.MinZoom = 0.2f;
  66.         mainSliceView.lbl = lbl; //TAKE THIS OUT
  67.         orthoSliceView[0].ViewType = VIEW_TYPE.TRANSVERSE;
  68.         orthoSliceView[0].IsRotatable = false;
  69.         orthoSliceView[1].ViewType = VIEW_TYPE.SAGITTAL;
  70.         orthoSliceView[1].IsRotatable = false;
  71.         orthoSliceView[2].ViewType = VIEW_TYPE.CORONAL; 
  72.         orthoSliceView[2].IsRotatable = false;
  73.  
  74.         //resume layout
  75.         this.ResumeLayout();
  76.  
  77.         this.Resize += new EventHandler(ViewPanel_Resize);
  78.     }
  79.  
  80.  
  81.     public void ViewPanel_Resize(object sender, EventArgs e)
  82.     {
  83.         int cx,cy;
  84.         cx = this.ClientSize.Width;
  85.         cy = this.ClientSize.Height;
  86.  
  87.         //set the main view and ortho big panels first
  88.         mainViewPanel.SetBounds(0,0,cx,(int)(cy*3/4.0));
  89.         orthoViewBigPanel.SetBounds(0,(int)(cy*3/4.0),cx,(int)(cy/4.0));
  90.  
  91.         //set the the ortho view panels second
  92.         cx = orthoViewBigPanel.Width;
  93.         cy = orthoViewBigPanel.Height;
  94.         
  95.         for(int i = 0; i < 3; i++)
  96.             orthoViewPanel[i].Size = new Size((int)(cx/3.0),cy);
  97.         
  98.     }
  99.  
  100.     public void LoadScan( Scan s )
  101.     {
  102.         mainSliceView.DisplayFromBuffer = true;
  103.         mainSliceView.LoadScan(s);
  104.         for(int i = 0; i < 3; i++)
  105.             orthoSliceView[i].LoadScan( s);
  106.  
  107.         //set the draw quality of the main panel to high
  108.         //smaller ortho views are defaulted to low quality
  109.         mainSliceView.DrawQuality = DRAW_QUALITY.HIGH;
  110.  
  111.         //set the view type of mainSlice to ortho3D
  112.         //smaller ortho views are defaulted to orthoD
  113.         //mainSliceView.ViewType = VIEW_TYPE.ORTHO_3D;
  114.     }
  115. }
  116.